package com.kangyi.app.controller;

import com.kangyi.dto.AppNursingPageQueryDTO;
import com.kangyi.dto.NursingHomeDetailDTO;
import com.kangyi.result.ListPageResult;
import com.kangyi.result.Result;
import com.kangyi.app.service.NursingHomeServices;
import com.kangyi.vo.NursingHomeDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author Blank
 * @version 1.0
 */
@RestController
@RequestMapping("/app/nursing")
@Slf4j
@Api(tags = "养老院相关接口 ")
public class NursingHomeController {

    @Autowired
    private NursingHomeServices nursingHomeService;


    @GetMapping("/list")
    @ApiOperation("养老院分页接口")
    public Result<ListPageResult> pageNursingHome(AppNursingPageQueryDTO appNursingPageQueryDTO){
        try {
            ListPageResult listPageResult = nursingHomeService.list(appNursingPageQueryDTO);
            return Result.success(listPageResult, "查询成功!");
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }

    @GetMapping("/detail")
    @ApiOperation("查询养老院详情")
    public Result<NursingHomeDetailVO> inquiryNursingHomeById(NursingHomeDetailDTO nursingHomeDetailDTO) {
        log.info("查询养老院详情: {}", nursingHomeDetailDTO);
        try {
            NursingHomeDetailVO nursingHomeDetailVO = nursingHomeService.inquiryNursingHomeById(nursingHomeDetailDTO);
            return Result.success(nursingHomeDetailVO, "查询成功!");
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }

}
